package com.lzx.iteam.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.lzx.iteam.R;
import com.lzx.iteam.bean.aidl.ActiveDetailBean;
import com.lzx.iteam.util.ImageLoaderInterface;

import java.util.ArrayList;

/**
 * Created by zhangshuai on 15/10/23.
 */
public class ActiveDetailAdapter extends BaseAdapter {

    private Context mContext;
    private ArrayList<ActiveDetailBean> mData;

    public ActiveDetailAdapter(Context mContext,ArrayList<ActiveDetailBean> mData){
        this.mContext = mContext;
        this.mData = mData;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null){
            holder = new ViewHolder();
            view = LayoutInflater.from(mContext).inflate(R.layout.active_apply_item_layout,null);
            holder.image = (ImageView) view.findViewById(R.id.active_item_image);
            holder.name = (TextView) view.findViewById(R.id.active_item_name);
            holder.phone = (TextView) view.findViewById(R.id.active_item_phone);
            view.setTag(holder);
        }else{
            holder = (ViewHolder) view.getTag();
        }
        ImageLoaderInterface.imageLoader.displayImage(mData.get(i).getImage(),holder.image,ImageLoaderInterface.optionHeadImage);
        holder.name.setText(mData.get(i).getName());
        holder.phone.setText(mData.get(i).getPhone());
        return view;
    }

    class ViewHolder{
        ImageView image;
        TextView name;
        TextView phone;
    }
}
